package com.qqtech.qquan.order.service;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.qqtech.core.common.util.StringUtil;
import com.qqtech.core.frame.dao.BaseDao;
import com.qqtech.core.frame.service.BaseServiceImpl;
import com.qqtech.qquan.order.dao.OrderDeliveryDao;
import com.qqtech.qquan.order.model.OrderDelivery;
import com.qqtech.qquan.order.model.OrderDeliveryQuery;

@Service
public class OrderDeliveryServiceImpl extends BaseServiceImpl<OrderDelivery>
		implements OrderDeliveryService {
	public static final Logger log = LoggerFactory.getLogger(OrderDeliveryServiceImpl.class);
	
	@Resource
	private OrderDeliveryDao orderDeliveryDao;

	@Override
	protected BaseDao<OrderDelivery> getBaseDao() {
		return orderDeliveryDao;
	}

	@Override
	public OrderDelivery getByOrderNoAndType(String orderNo, Integer type) {
		OrderDelivery value = null;
		if (!StringUtil.isBlank(orderNo) && type != null) {
			OrderDeliveryQuery q = new OrderDeliveryQuery();
			q.setOrderNo(orderNo);
			q.setType(type);
			List<OrderDelivery> list = orderDeliveryDao.queryList(q);
			if (list != null && !list.isEmpty()) {
				value = list.get(0);
			}
		}
		return value;
	}

	@Override
	public OrderDelivery getByOrderNo(String orderNo) {
		OrderDelivery value = null;
		if (StringUtil.isNotBlank(orderNo)) {
			OrderDeliveryQuery q = new OrderDeliveryQuery();
			q.setOrderNo(orderNo);
			List<OrderDelivery> list = orderDeliveryDao.queryList(q);
			if (list != null && list.size()>0) {
				value = list.get(0);
			}
		}
		return value;
	}
	
}